#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <tuple>
#include <vector>
constexpr int MaxN = 8e5 + 5;
int n;
int idx;
int f[MaxN];
int fa[MaxN];
int id[MaxN];
int top[MaxN];
int son[MaxN];
int size[MaxN];
int value[MaxN];
int depth[MaxN];
int st[24][MaxN];
std::vector<std::tuple<int, int>> links;
std::vector<std::tuple<int, int>> g[MaxN];
int find(int x)
{
    return f[x] == x ? x : f[x] = find(f[x]);
}
inline void merge(int x, int y)
{
    int fx, fy;
    fx = find(x);
    fy = find(y);
    if (fx != fy)
    {
        f[fx] = fy;
    }
}
void dfs_info(int u, int f)
{
    fa[u] = f;
    depth[u] = depth[f] + 1;
    size[u] = 1;
    for (auto k : g[u])
    {
        int v, w;
        std::tie(v, w) = k;
        if (v == f)
        {
            continue;
        }
        value[v] = w;
        dfs_info(v, u);
        if (size[v] > size[son[u]])
        {
            son[u] = v;
        }
        size[u] += size[v];
    }
}
void dfs_split(int u, int f, int t)
{
    top[u] = t;
    id[u] = ++idx;
    if (son[u] != 0)
    {
        dfs_split(son[u], u, t);
    }
    for (auto k : g[u])
    {
        int v;
        std::tie(v, std::ignore) = k;
        if (v == f || v == son[u])
        {
            continue;
        }
        dfs_split(v, u, v);
    }
}
inline int query_min(int l, int r)
{
    if (l > r)
    {
        return 0x7f7f7f7f;
    }
    int j = std::log2(r - l + 1);
    return std::min(st[j][l], st[j][r - (1 << j) + 1]);
}
inline int query(int x, int y)
{
    int res = 0x7f7f7f7f;
    for (; top[x] != top[y];)
    {
        if (depth[top[x]] < depth[top[y]])
        {
            std::swap(x, y);
        }
        res = std::min(res, query_min(id[top[x]], id[x]));
        x = fa[top[x]];
    }
    if (depth[x] > depth[y])
    {
        std::swap(x, y);
    }
    res = std::min(res, query_min(id[x] + 1, id[y]));
    return res;
}
int main()
{
    freopen("tatooine.in", "r", stdin);
    freopen("tatooine.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; i++)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        g[u].push_back({v, w});
        g[v].push_back({u, w});
        links.push_back({u, v});
    }
    dfs_info(1, 0);
    dfs_split(1, 0, 1);
    for (int i = 1; i <= n; i++)
    {
        st[0][i] = value[i];
    }
    for (int j = 1; j < 24; j++)
    {
        for (int i = 1; i + (1 << j) - 1 <= n; i++)
        {
            st[j][i] = std::min(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);
        }
    }
    for (auto k : links)
    {
        std::iota(f + 1, f + 1 + n, 1);
        for (auto l : links)
        {
            if (k == l)
            {
                continue;
            }
            merge(std::get<0>(l), std::get<1>(l));
        }
        long long answer = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (find(i) == find(j))
                {
                    answer += query(i, j);
                }
            }
        }
        printf("%lld\n", answer);
    }
    return 0;
}